package com.d0318;

import java.util.Date;

public class JoinTester implements Runnable {
    private String name;
    private int timer;
    public JoinTester(String name,int timer){
        this.name=name;
        this.timer=timer;
    }
    @Override
    public void run() {
        System.out.println(name+"线程开始于:"+new Date());
       try {
            Thread.sleep(timer);


        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name+"线程结束与："+new Date());
    }

    public static void main(String[] args) {
        Thread thread=new Thread(new JoinTester("one",3000));
        Thread thread1=new Thread(new JoinTester("two",4000));


        thread1.start();
        thread.start();
        try {
            thread.join();
            thread1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("主线程结束");
    }
}
